﻿<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<!--#include file="Check_Sql.asp"-->
<%
'=================================================
'过程名：ShowNavigation
'作  用：显示导航栏
'参  数：无
'=================================================
sub ShowNavigation()
	response.write  ""
	response.write  ""
end sub
%>
<%
'=================================================
'过程名：ShowSlide
'作  用：显示文章分类列表
'参  数：条数
'=================================================
sub ShowSlide(count)
	Set rs= Server.CreateObject("ADODB.Recordset")
	rsStr =	"SELECT TOP "&count&" articles.articleID,articles.imageshot,articles.title"
	rsStr = rsStr&" "&"FROM articles"
	rsStr = rsStr&" "&"WHERE articles.isSlideShow=true AND imageshot<>''"
	rsStr = rsStr&" "&"ORDER by articles.createTime DESC"
	rs.open rsStr,conn,1,1
	if rs.eof or rs.bof then
%>
	<p>暂时没有图片新闻</p>
<%	else%>
<script type="text/javascript" src="js/jquery.KinSlideshow-1.2.1.min.js"></script>
<script type="text/javascript">
$(function(){
        $("#KinSlideshow").KinSlideshow({
				intervalTime:3,
                titleBar:{titleBar_height:30},
                btn:{btn_bgColor:"#FFFFFF",btn_bgHoverColor:"#FF0099",btn_fontColor:"#000000",
                     btn_fontHoverColor:"#FFFFFF",btn_borderWidth:0}
        });
    });
</script>
<div id="KinSlideshow" style="visibility:hidden; float:left;">
<%
		do while not rs.eof
%>
	<a href="article.asp?id=<%=rs("articleID")%>" target="_blank"><img src="<%=rs("imageshot")%>" alt="<%=rs("title")%>"/></a>
<%			rs.movenext
		loop
%>
</div>
<%
	end if
	set rs=nothing
end sub
%>
<%
'=================================================
'过程名：ShowLinkClassList
'作  用：显示链接分类列表
'参  数：分类号，条数，是否显示图片信息
'=================================================
sub ShowLinkClassList(id,count,showimg,showtitle)
	response.write "<ul>"
	Set rs= Server.CreateObject("ADODB.Recordset")
	rsStr =	"SELECT TOP "&count&" title,url,img"
	rsStr = rsStr&" "&"FROM links"
	rsStr = rsStr&" "&"WHERE links.classID = "&id
	rsStr = rsStr&" "&"ORDER by linkID ASC"
	rs.open rsStr,conn,1,1
	if rs.eof or rs.bof then
%>
	<li>暂时没有记录</li>
<%	
	else
		do while not rs.eof
%>
	<li><a href="<%=rs("url")%>" target="_blank"><%if showimg=true and rs("img")<>""then%><img src="<%=rs("img")%>" alt="<%=rs("title")%>"/><%end if%><%if showtitle=true then%><%=rs("title")%><%end if%></a></li>
<%			rs.movenext
		loop
	end if
	response.write  "</ul>"
	set rs=nothing
end sub
%>
<%
'=================================================
'过程名：ShowSpecialList
'作  用：显示专题
'参  数：条数
'=================================================
sub ShowSpecialList(count,showtime,showtitle,showimg)
	if count>0 then
		response.write "<ul>"
		Set rs= Server.CreateObject("ADODB.Recordset")
		rsStr =	"SELECT TOP "&count&" *"
		rsStr = rsStr&" "&"FROM special"
		rsStr = rsStr&" "&"ORDER by specialID DESC"
		rs.open rsStr,conn,1,1
		if rs.eof or rs.bof then
%>
		<li>暂时没有记录</li>
<%	
		else
			do while not rs.eof
%>
		<li><%if showtime=true then%><span class="pubtime"><%=rs("createTime")%></span><%end if%><a href="special.asp?id=<%=rs("specialID")%>"><%if showimg=true and rs("img")<>""then%><img src="<%=rs("img")%>" alt="<%=rs("specialName")%>"/><%end if%><%if showtitle=true then%><%=rs("specialName")%><%end if%></a></li>
<%			rs.movenext
			loop
		end if
		response.write  "</ul>"
		set rs=nothing
	else 
	'分页显示
		If Not IsNumeric(Request("p")) Or IsEmpty(Request("p")) Or Request("p") <=0 Then
			Pagenum=1
		Else
			Pagenum=Int(Abs(Request("p")))
		End if
		Set rs=server.CreateObject("ADODB.RecordSet")
		rsStr="SELECT * FROM special ORDER by specialID DESC"
		rs.Open rsStr,conn,1,3
		rs.PageSize		= Pagesize
		MaxPages		= rs.PageCount
		rs.absolutepage	= Pagenum
		total			= rs.RecordCount
		If Not rs.eof then
			i = 0
			do until rs.Eof or i = rs.PageSize
		%>	  
				<li><%if showtime=true then%><span class="pubtime"><%=rs("createTime")%></span><%end if%><a href="special.asp?id=<%=rs("specialID")%>"><%if showimg=true and rs("img")<>""then%><img src="<%=rs("img")%>" alt="<%=rs("specialName")%>"/><%end if%><%if showtitle=true then%><%=rs("specialName")%><%end if%></a></li>
		<%
				rs.MoveNext
                i = i + 1
			loop
			call ShowPageNav()
		%>
		<%else %>
		<li>暂时没有记录</li>
<%		end if
	end if
end sub

sub ShowPageNav()
end sub%>
<%
'=================================================
'过程名：ShowArticleClassList
'作  用：显示文章分类列表
'参  数：分类号，条数，是否显示发布时间，是否显示分类信息，是否显示图片信息
'=================================================
sub ShowArticleClassList(id,count,showtime,showclass,showimg)
	response.write "<ul>"
	Set rs= Server.CreateObject("ADODB.Recordset")
	rsStr =	"SELECT TOP "&count&" articles.articleID,articles.title,articles.createTime,articles.classID,articles.imageshot,class.className"
	rsStr = rsStr&" "&"FROM articles,class"
	rsStr = rsStr&" "&"WHERE articles.classID = "&id&" AND articles.classID=class.classID"
	rsStr = rsStr&" "&"ORDER by articles.createTime DESC"
	rs.open rsStr,conn,1,1
	if rs.eof or rs.bof then
%>
	<li>暂时没有记录</li>
<%	
	else
		do while not rs.eof
%>
	<li>	
		<%if showtime=true then%><span class="pubtime"><%=rs("createTime")%></span><%end if%>
		<%if showclass=true then%><a href="class.asp?id=<%=rs("classID")%>" target="_self">[<%=rs("className")%>]</a><%end if%>
		<a href="article.asp?id=<%=rs("articleID")%>" target="_self">
			<%if showimg=true and rs("imageshot")<>""then%><img src="<%=rs("imageshot")%>" alt="<%=rs("title")%>"/><%end if%>
			<%=rs("title")%>
		</a>
	</li>
<%			rs.movenext
		loop
	end if
	response.write  "</ul>"
	set rs=nothing
end sub
%>
<%
'=================================================
'过程名：ShowPageClassList
'作  用：显示文章分类列表
'参  数：分类号，条数，是否显示发布时间，是否显示分类信息,显示封面
'=================================================
sub ShowPageClassList(id,count,showtime,showclass,showimg)
	response.write  "<ul>"
	Set rs= Server.CreateObject("ADODB.Recordset")
	rsStr =	"SELECT TOP "&count&" pages.pageID,pages.title,pages.createTime,pages.classID,class.className"
	rsStr = rsStr&" "&"FROM pages,class"
	rsStr = rsStr&" "&"WHERE pages.classID = "&id&" AND pages.classID=class.classID"
	rsStr = rsStr&" "&"ORDER by pages.createTime DESC"
	rs.open rsStr,conn,1,1
	if rs.eof or rs.bof then
%>
	<li>暂时没有记录</li>
<%	
	else
	
		do while not rs.eof
%>
	<li>	
		<%if showtime=true then%><span class="pubtime"><%=rs("createTime")%></span><%end if%>
		<%if showclass=true then%><a href="class.asp?id=<%=rs("classID")%>" target="_self">[<%=rs("className")%>]</a><%end if%>
		<a href="page.asp?id=<%=rs("pageID")%>" target="_self">
			<%=rs("title")%>
		</a>
	</li>
<%			rs.movenext
		loop
	end if
	response.write  "</ul>"
	set rs=nothing
end sub
%>
<%
'=================================================
'过程名：ShowPhotoClassList
'作  用：显示文章分类列表
'参  数：分类号，条数，是否显示发布时间，是否显示分类信息，是否显示图片
'=================================================
sub ShowPhotoClassList(id,count,showtime,showclass,showimg)
	response.write  "<ul>"
	Set rs= Server.CreateObject("ADODB.Recordset")
	rsStr =	"SELECT TOP "&count&" photos.photoID,photos.title,photos.classID,photos.url,class.className"
	rsStr = rsStr&" "&"FROM photos,class"
	rsStr = rsStr&" "&"WHERE photos.classID = "&id&" AND photos.classID=class.classID"
	rsStr = rsStr&" "&"ORDER by photos.createTime DESC"
	rs.open rsStr,conn,1,1
	if rs.eof or rs.bof then
%>
	<li>暂时没有记录</li>
<%	
	else
		do while not rs.eof
%>
	<li>	
		<%if showclass=true then%><a href="class.asp?id=<%=rs("classID")%>" target="_self">[<%=rs("className")%>]</a><%end if%>
		<a href="photo.asp?id=<%=rs("photoID")%>" target="_self">
			<%=rs("title")%>
		</a>
	</li>
<%			rs.movenext
		loop
	end if
	response.write "</ul>"
	set rs=nothing
end sub
%>
<%
'=================================================
'过程名：ShowUserLogin
'作  用：显示用户登录表单
'参  数：无
'=================================================
sub ShowUserLogin()
	dim strLogin
	If Session("UserName")="" Then
    	strLogin= "<form action='user.asp?act=login' method='post' name='userLogin' onsubmit='return CheckForm();'>"
		strLogin=strLogin & "<label for='username'>用户名</label><input name='username' type='text' id='username' maxlength='20'/><br />"
		strLogin=strLogin & "<label for='password'>密　码</label><input name='password' type='password' id='password' maxlength='20'/><br />"
		strLogin=strLogin & "<input name='Login' type='submit' id='Login' value='登 录'>"
		strLogin=strLogin & "<input name='Reset' type='reset' id='Reset' value='清 除'><br />"
		strLogin=strLogin & "<a href='user.asp?act=reg' target='_blank'>新用户注册</a>&nbsp;&nbsp;<a href='user.asp?act=getpsw' target='_blank'>忘记密码</a>"
		strLogin=strLogin & "</form>"
		response.write strLogin
%>
<script language=javascript>
	function CheckForm()
	{
		if(document.userLogin.username.value=="")
		{
			alert("请输入用户名！");
			document.userLogin.username.focus();
			return false;
		}
		if(document.userLogin.password.value == "")
		{
			alert("请输入密码！");
			document.userLogin.password.focus();
			return false;
		}
	}
</script>
<%
	Else 
		strLogin= ""
		strLogin=strLogin& "欢迎您！" & Session("UserName") & "<br/>"
		strLogin=strLogin& "<a href='user.asp?act=server'>管理</a>"
		strLogin=strLogin& "<a href='user.asp?act=logout'>退出</a>"
		strLogin=strLogin& ""
		response.write strLogin
	end if
end sub
%>
<%
'=================================================
'过程名：ShowArticle
'作  用：显示文章
'参  数：文章id
'=================================================
sub ShowArticle(id)
	Set rs= Server.CreateObject("ADODB.Recordset")
	rsStr =	"SELECT articles.*,class.className"
	rsStr = rsStr&" "&"FROM articles,class"
	rsStr = rsStr&" "&"WHERE articles.articleID = "&id&" AND articles.classID=class.classID"
	rs.open rsStr,conn,1,1
	if rs.eof or rs.bof then
%>
	<div class="error">文章不存在</div>
<%	
	else
%>
<article>
	<h2 class="article-titile"><%=rs("title")%></h2>
	<div class="article-info"><%if rs("origin") then%><strong>来源：</strong><%=rs("origin")%><%end if%><strong>发布时间：</strong><%=rs("createTime")%><strong>阅读数：</strong><%=rs("click")%></div>
	<div class="article-content">
		<%=rs("content")%>
	</div>
</article>
<%	
	conn.execute("update articles Set click=click+1 where articleID=" & id ) '点击数+1
	end if
	set rs=nothing
end sub
%>
<%
'=================================================
'过程名：ShowPage
'作  用：显示页面
'参  数：页面id
'=================================================
sub ShowPage(id)
	Set rs= Server.CreateObject("ADODB.Recordset")
	rsStr =	"SELECT pages.*,class.className"
	rsStr = rsStr&" "&"FROM pages,class"
	rsStr = rsStr&" "&"WHERE pages.pageID = "&id&" AND pages.classID=class.classID"
	rs.open rsStr,conn,1,1
	if rs.eof or rs.bof then
%>
	<div class="error">页面不存在</div>
<%	
	else
%>
<article>
	<h2 class="article-titile"><%=rs("title")%></h2>
	<div class="article-content">
		<%=rs("content")%>
	</div>
</article>
<%	
	conn.execute("update pages set click=click+1 where pageID=" & id ) '点击数+1
	end if
	set rs=nothing
end sub
%>
<%
'=================================================
'函数名：getClasstype
'作  用：获取分类类型
'参  数：分类id
'返回值：分类类型
'=================================================
function getClasstype(id)
	Set rs= Server.CreateObject("ADODB.Recordset")
	rsStr =	"SELECT classtype"
	rsStr = rsStr&" "&"FROM class"
	rsStr = rsStr&" "&"WHERE classID = "&id
	rs.open rsStr,conn,1,1
	if rs.eof or rs.bof then
%>
	<div class="error">分类不存在</div>
<%	
	else
	getClasstype=rs("classtype") 
	end if
	set rs=nothing
end function
%>
<%
'=================================================
'函数名：getClassID
'作  用：获取分类id
'参  数：id,类型
'返回值：classID
'=================================================
function getClassID(id,classtypename)
	Set rs= Server.CreateObject("ADODB.Recordset")
	rs.open "SELECT classID FROM "&classtypename&"s WHERE "&classtypename&"ID = "&id,conn,1,1
	if rs.eof or rs.bof then
%>
	<div class="error"></div>
<%	
	else
	getClassID=rs("classID") 
	end if
	set rs=nothing
end function
%>
<%
'=================================================
'过程名：classLocation
'作  用：显示页面
'参  数：页面id
'=================================================
sub classLocation(id)
	Set rs= Server.CreateObject("ADODB.Recordset")
	rsStr =	"SELECT classID,className,parentID"
	rsStr = rsStr&" "&"FROM class"
	rsStr = rsStr&" "&"WHERE classID = "&id
	rs.open rsStr,conn,1,1
	if not (rs.eof or rs.bof) then
		if rs("parentID")<>0 then
		call classLocation(rs("parentID"))
		end if
%>
>><a href="class.asp?id=<%=rs("classID")%>"><%=rs("className")%></a>
<%      
	end if
end sub%>
<%
'=================================================
'过程名：classTree
'作  用：显示分类树
'参  数：分类id
'=================================================
sub classTree(id)
	Set rs= Server.CreateObject("ADODB.Recordset")
	rsStr =	"SELECT classID,className,parentID"
	rsStr = rsStr&" "&"FROM class"
	rsStr = rsStr&" "&"WHERE classID = "&id
	rs.open rsStr,conn,1,1
	if not (rs.eof or rs.bof) then
		if rs("parentID")=0 then
%>
	<h2><a href="class.asp?id=<%=rs("classID")%>"><%=rs("className")%></a></h2>
<%		
		call classTreeBulid(rs("classID"))
		else 
    	call classTree(rs("parentID"))		
		end if
	end if
end sub
sub classTreeBulid(id)
	Set rs= Server.CreateObject("ADODB.Recordset")
	rsStr =	"SELECT classID,className,parentID"
	rsStr = rsStr&" "&"FROM class"
	rsStr = rsStr&" "&"WHERE parentID = "&id
	rs.open rsStr,conn,1,1
	if not (rs.eof or rs.bof) then
	response.write "<ul>"
		while not rs.eof
%>
		<li><a href="class.asp?id=<%=rs("classID")%>"><%=rs("className")%></a></li>
<%		call classTreeBulid(rs("classID"))
		rs.movenext
		wend
	response.write"</ul>"
	end if	
end sub%>
